package com.mtao.utils;

import lombok.Data;
import org.springframework.stereotype.Component;
import org.springframework.web.multipart.MultipartFile;

import java.util.UUID;

@Data
@Component
public class FileUtil {
    public String upload(MultipartFile file){
        String originalFilename = file.getOriginalFilename();
        //保证文件名字唯一
        String fileName= UUID.randomUUID().toString()+originalFilename.substring(originalFilename.lastIndexOf("."));
        // 填写Object完整路径，完整路径中不能包含Bucket名称，例如exampledir/exampleobject.txt。
        String objectName = "img/"+fileName;
        return objectName;
    }
}
